-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide ToString
specializations behind a private trait
#89253
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
eacc349
to
e42b1aa
Compare
but isn't |
|
actually #32586 (comment) questioned the rationale of making
what i interpret is that there's no preference in wanting either way. afaik no conventions RFC exists yet. has any experimentation been done?
IMO creating a private-but-actually-public |
While not technically being an RFC, the std-dev-guide specifies that specialization should use private traits https://std-dev-guide.rust-lang.org/code-considerations/using-unstable-lang/specialization.html
I agree with that, however at least the change makes it consistent with how specialization is handled in the rest of the stdlib. |
IIRC the reason for hiding specializations had something to do with the specialized methods being nameable through fully qualified function calls, e.g. |
☔ The latest upstream changes (presumably #92598) made this pull request unmergeable. Please resolve the merge conflicts. |
Normally we use private traits for specializing
impl
s butToString
's were public and the original PR #32586 doesn't seem to have a reason for this. This PR moves those impls to a hidden perma-unstableSpecToString
trait (I would have made it private ifproc_macro
didn't have to specialize it too) and delegates to it, leaving only theimpl<T: fmt::Display + ?Sized> ToStringSpec for T
as public.